package com.feicheng.mapper;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.feicheng.base.result.Result;
import com.feicheng.entity.Stock;
import com.feicheng.model.StockAndProduct;
import com.feicheng.model.StockandProductandWarehouse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhennan.liu
 * @since 2022-07-04
 */
@Repository
@Mapper
public interface StockMapper extends BaseMapper<Stock> {

    /**
     * 通过产品id和仓库id查询 库存数量
     * @author zhennan.liu
     * @param productId
     * @param warehouseId
     * @return
     */
    @Select("select stock_id,num,product_id,warehouse_id from stock where warehouse_id = #{warehouseId} and product_id = #{productId}")
    Stock selectAllByid(@Param("productId") Integer productId,
                        @Param("warehouseId") Integer warehouseId);

    /**
     * 库存列表条件查询
     * @param stockandProductandWarehouse
     * @return
     */
    Result selectListbylong(StockandProductandWarehouse stockandProductandWarehouse);

    /**
     * @param page
     * @param wrapper
     * @return
     * @autor tao,jiang
     * @see
     */
    Page<StockAndProduct> selectstock(
            Page<StockAndProduct> page,
            @Param(Constants.WRAPPER) Wrapper wrapper);
}
